<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./jquery.js"></script>
    <style>
        html,
        body {
            margin: 0;
            padding: 0;
            overflow: hidden;
        }

        #tianshi {
            position: absolute;
        }
    </style>
</head>

<body>
    <img src="./angel.gif" title="天使" id="tianshi">
    <script>
        $(function () {
            var angel = $('#tianshi')
            // var timer = true;
            var timer = null
            // 2. 绑定 mousemove 事件
            $(document).on('mousemove', function (e) {
                // 步骤3：判断节流阀是否为空
                if (timer) {
                    return
                }
                // 3. 设置图片的位置
                // 步骤2：开启延时器
                timer = setTimeout(function () {
                    $(angel).css('top', e.pageY + 'px').css('left', e.pageX + 'px')
                    console.log('ok')
                    timer = null
                }, 16)
            })
        })
    </script>
</body>

</html>